home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / Delphi.Net / CLR / GraphEx / GraphWin.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-10-22  |  20.2 KB  |  954 lines

  1. unit GraphWin;
  2.  
  3.  
  4. interface
  5.  
  6. uses
  7.     Borland.Delphi.SysUtils,
  8.     Borland.Win32.Windows,
  9.     Borland.Win32.Messages,
  10.     Borland.Delphi.Classes,
  11.     Borland.Vcl.Graphics,
  12.     Borland.Vcl.Controls,
  13.     Borland.Vcl.Forms,
  14.     Borland.Vcl.Dialogs,
  15.     Borland.Vcl.Buttons,
  16.     Borland.Vcl.ExtCtrls,
  17.     Borland.Vcl.StdCtrls,
  18.     Borland.Vcl.Menus;
  19.  
  20. type
  21.   TDrawingTool = (dtLine, dtRectangle, dtEllipse, dtRoundRect);
  22.   TForm1 = class(TForm)
  23.     Panel1: TPanel;
  24.     LineButton: TSpeedButton;
  25.     RectangleButton: TSpeedButton;
  26.     EllipseButton: TSpeedButton;
  27.     RoundRectButton: TSpeedButton;
  28.     PenButton: TSpeedButton;
  29.     BrushButton: TSpeedButton;
  30.     PenBar: TPanel;
  31.     BrushBar: TPanel;
  32.     SolidPen: TSpeedButton;
  33.     DashPen: TSpeedButton;
  34.     DotPen: TSpeedButton;
  35.     DashDotPen: TSpeedButton;
  36.     DashDotDotPen: TSpeedButton;
  37.     ClearPen: TSpeedButton;
  38.     PenSize: TEdit;
  39. //    StatusBar1: TStatusBar;
  40.     StatusBar1: TPanel;
  41.     ScrollBox1: TScrollBox;
  42.     Image: TImage;
  43.     SolidBrush: TSpeedButton;
  44.     ClearBrush: TSpeedButton;
  45.     HorizontalBrush: TSpeedButton;
  46.     VerticalBrush: TSpeedButton;
  47.     FDiagonalBrush: TSpeedButton;
  48.     BDiagonalBrush: TSpeedButton;
  49.     CrossBrush: TSpeedButton;
  50.     DiagCrossBrush: TSpeedButton;
  51.     PenColor: TSpeedButton;
  52.     BrushColor: TSpeedButton;
  53.     ColorDialog1: TColorDialog;
  54.     MainMenu1: TMainMenu;
  55.     File1: TMenuItem;
  56.     New1: TMenuItem;
  57.     Open1: TMenuItem;
  58.     Save1: TMenuItem;
  59.     Saveas1: TMenuItem;
  60.     N1: TMenuItem;
  61.     Exit1: TMenuItem;
  62.     Edit1: TMenuItem;
  63.     Cut1: TMenuItem;
  64.     Copy1: TMenuItem;
  65.     Paste1: TMenuItem;
  66.     OpenDialog1: TOpenDialog;
  67.     SaveDialog1: TSaveDialog;
  68.     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
  69.       Shift: TShiftState; X, Y: Integer);
  70.     procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
  71.       Shift: TShiftState; X, Y: Integer);
  72.     procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  73.       Y: Integer);
  74.     procedure LineButtonClick(Sender: TObject);
  75.     procedure RectangleButtonClick(Sender: TObject);
  76.     procedure EllipseButtonClick(Sender: TObject);
  77.     procedure RoundRectButtonClick(Sender: TObject);
  78.     procedure PenButtonClick(Sender: TObject);
  79.     procedure BrushButtonClick(Sender: TObject);
  80.     procedure SetPenStyle(Sender: TObject);
  81.     procedure PenSizeChange(Sender: TObject);
  82.     procedure FormCreate(Sender: TObject);
  83.     procedure SetBrushStyle(Sender: TObject);
  84.     procedure PenColorClick(Sender: TObject);
  85.     procedure BrushColorClick(Sender: TObject);
  86.     procedure Exit1Click(Sender: TObject);
  87.     procedure Open1Click(Sender: TObject);
  88.     procedure Save1Click(Sender: TObject);
  89.     procedure Saveas1Click(Sender: TObject);
  90.     procedure New1Click(Sender: TObject);
  91.     procedure Copy1Click(Sender: TObject);
  92.     procedure Cut1Click(Sender: TObject);
  93.     procedure Paste1Click(Sender: TObject);
  94.   private
  95.     { Private declarations }
  96.         procedure InitializeControls;
  97.   public
  98.     { Public declarations }
  99.     BrushStyle: TBrushStyle;
  100.     PenStyle: TPenStyle;
  101.     PenWide: Integer;
  102.     Drawing: Boolean;
  103.     Origin, MovePt: TPoint;
  104.     DrawingTool: TDrawingTool;
  105.     CurrentFile: string;
  106.         constructor Create(AOwner: TComponent); override;
  107.     procedure SaveStyles;
  108.     procedure RestoreStyles;
  109.     procedure DrawShape(TopLeft, BottomRight: TPoint; AMode: TPenMode);
  110.   end;
  111.  
  112. var
  113.   Form1: TForm1;
  114.  
  115. implementation
  116.  
  117. uses
  118.     BMPDlg
  119.     ;
  120.  
  121.  
  122. procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  123.   Shift: TShiftState; X, Y: Integer);
  124. begin
  125.   Drawing := True;
  126.   Image.Canvas.MoveTo(X, Y);
  127.   Origin := Point(X, Y);
  128.   MovePt := Origin;
  129. //  StatusBar1.Panels[0].Text := Format('Origin: (%d, %d)', [X, Y]);
  130.   StatusBar1.Caption := Format('Origin: (%d, %d)', [X, Y]);
  131. end;
  132.  
  133. procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  134.   Shift: TShiftState; X, Y: Integer);
  135. begin
  136.   if Drawing then
  137.   begin
  138.     DrawShape(Origin, Point(X, Y), pmCopy);
  139.     Drawing := False;
  140.   end;
  141. end;
  142.  
  143. procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  144.   Y: Integer);
  145. begin
  146.   if Drawing then
  147.   begin
  148.     DrawShape(Origin, MovePt, pmNotXor);
  149.     MovePt := Point(X, Y);
  150.     DrawShape(Origin, MovePt, pmNotXor);
  151.   end;
  152. //  StatusBar1.Panels[1].Text := Format('Current: (%d, %d)', [X, Y]);
  153.   StatusBar1.Caption := Format('Current: (%d, %d)', [X, Y]);
  154. end;
  155.  
  156. procedure TForm1.LineButtonClick(Sender: TObject);
  157. begin
  158.   DrawingTool := dtLine;
  159. end;
  160.  
  161. procedure TForm1.RectangleButtonClick(Sender: TObject);
  162. begin
  163.   DrawingTool := dtRectangle;
  164. end;
  165.  
  166. procedure TForm1.EllipseButtonClick(Sender: TObject);
  167. begin
  168.   DrawingTool := dtEllipse;
  169. end;
  170.  
  171. procedure TForm1.RoundRectButtonClick(Sender: TObject);
  172. begin
  173.   DrawingTool := dtRoundRect;
  174. end;
  175.  
  176. procedure TForm1.DrawShape(TopLeft, BottomRight: TPoint; AMode: TPenMode);
  177. begin
  178.   with Image.Canvas do
  179.   begin
  180.     Pen.Mode := AMode;
  181.     case DrawingTool of
  182.       dtLine:
  183.         begin
  184.           Image.Canvas.MoveTo(TopLeft.X, TopLeft.Y);
  185.           Image.Canvas.LineTo(BottomRight.X, BottomRight.Y);
  186.         end;
  187.       dtRectangle: Image.Canvas.Rectangle(TopLeft.X, TopLeft.Y, BottomRight.X,
  188.         BottomRight.Y);
  189.       dtEllipse: Image.Canvas.Ellipse(Topleft.X, TopLeft.Y, BottomRight.X,
  190.         BottomRight.Y);
  191.       dtRoundRect: Image.Canvas.RoundRect(TopLeft.X, TopLeft.Y, BottomRight.X,
  192.         BottomRight.Y, (TopLeft.X - BottomRight.X) div 2,
  193.         (TopLeft.Y - BottomRight.Y) div 2);
  194.     end;
  195.   end;
  196. end;
  197.  
  198. procedure TForm1.PenButtonClick(Sender: TObject);
  199. begin
  200. //  PenBar.Visible := PenButton.Down;
  201.   PenBar.Visible := true;
  202. end;
  203.  
  204. procedure TForm1.BrushButtonClick(Sender: TObject);
  205. begin
  206. //  BrushBar.Visible := BrushButton.Down;
  207.   BrushBar.Visible := True;
  208. end;
  209.  
  210. procedure TForm1.SetPenStyle(Sender: TObject);
  211. begin
  212.   with Image.Canvas.Pen do
  213.   begin
  214.     if Sender = SolidPen then Style := psSolid
  215.     else if Sender = DashPen then Style := psDash
  216.     else if Sender = DotPen then Style := psDot
  217.     else if Sender = DashDotPen then Style := psDashDot
  218.     else if Sender = DashDotDotPen then Style := psDashDotDot
  219.     else if Sender = ClearPen then Style := psClear;
  220.   end;
  221. end;
  222.  
  223. procedure TForm1.PenSizeChange(Sender: TObject);
  224. begin
  225. //  Image.Canvas.Pen.Width := PenWidth.Position;
  226.   Image.Canvas.Pen.Width := StrToInt(PenSize.Text);
  227. end;
  228.  
  229. procedure TForm1.FormCreate(Sender: TObject);
  230. var
  231.   Bitmap: TBitmap;
  232. begin
  233.   Bitmap := nil;
  234.   try
  235.     Bitmap := TBitmap.Create;
  236.     Bitmap.Width := 400;
  237.     Bitmap.Height := 400;
  238.     Bitmap.Canvas.Brush.Color := clWhite;
  239.     Bitmap.Canvas.FloodFill(20,20,clBlack,fsBorder);
  240.     
  241.     Image.Picture.Graphic := Bitmap;
  242.   finally
  243.     Bitmap.Free;
  244.   end;
  245. end;
  246.  
  247. procedure TForm1.SetBrushStyle(Sender: TObject);
  248. begin
  249.   TSpeedButton(Sender).Glyph.Canvas.Refresh;
  250.   with Image.Canvas.Brush do
  251.   begin
  252.     if Sender = SolidBrush then Style := bsSolid
  253.     else if Sender = ClearBrush then Style := bsClear
  254.     else if Sender = HorizontalBrush then Style := bsHorizontal
  255.     else if Sender = VerticalBrush then Style := bsVertical
  256.     else if Sender = FDiagonalBrush then Style := bsFDiagonal
  257.     else if Sender = BDiagonalBrush then Style := bsBDiagonal
  258.     else if Sender = CrossBrush then Style := bsCross
  259.     else if Sender = DiagCrossBrush then Style := bsDiagCross;
  260.   end;
  261. end;
  262.  
  263. procedure TForm1.PenColorClick(Sender: TObject);
  264. begin
  265.   ColorDialog1.Color := Image.Canvas.Pen.Color;
  266.   if ColorDialog1.Execute then
  267.     Image.Canvas.Pen.Color := ColorDialog1.Color;
  268. end;
  269.  
  270. procedure TForm1.BrushColorClick(Sender: TObject);
  271. begin
  272.   ColorDialog1.Color := Image.Canvas.Brush.Color;
  273.   if ColorDialog1.Execute then
  274.     Image.Canvas.Brush.Color := ColorDialog1.Color;
  275. end;
  276.  
  277. procedure TForm1.Exit1Click(Sender: TObject);
  278. begin
  279.   Close;
  280. end;
  281.  
  282. procedure TForm1.Open1Click(Sender: TObject);
  283. begin
  284.   if OpenDialog1.Execute then
  285.   begin
  286.     CurrentFile := trim(OpenDialog1.FileName);
  287.     SaveStyles;
  288.     Image.Picture.LoadFromFile(CurrentFile);
  289.     RestoreStyles;
  290.   end;
  291. end;
  292.  
  293. procedure TForm1.Save1Click(Sender: TObject);
  294. begin
  295. //  if CurrentFile <> EmptyStr then
  296.   if CurrentFile <> '' then
  297.     Image.Picture.SaveToFile(CurrentFile)
  298.   else SaveAs1Click(Sender);
  299. end;
  300.  
  301. procedure TForm1.Saveas1Click(Sender: TObject);
  302. begin
  303.   if SaveDialog1.Execute then
  304.   begin
  305.     CurrentFile := trim(SaveDialog1.FileName);
  306.     Save1Click(Sender);
  307.   end;
  308. end;
  309.  
  310. procedure TForm1.New1Click(Sender: TObject);
  311. var
  312.   Bitmap: TBitmap;
  313. begin
  314.   with NewBMPForm do
  315.   begin
  316.     WidthEdit.Text := IntToStr(Image.Picture.Graphic.Width);
  317.     HeightEdit.Text := IntToStr(Image.Picture.Graphic.Height);
  318.     if ShowModal <> idCancel then
  319.     begin
  320.       Bitmap := nil;
  321.       try
  322.         Bitmap := TBitmap.Create;
  323.         Bitmap.Width := StrToInt(WidthEdit.Text);
  324.         Bitmap.Height := StrToInt(HeightEdit.Text);
  325.         SaveStyles;
  326.         Image.Picture.Graphic := Bitmap;
  327.         RestoreStyles;
  328. //        CurrentFile := EmptyStr;
  329.         CurrentFile := '';
  330.       finally
  331.         Bitmap.Free;
  332.       end;
  333.     ActiveControl := WidthEdit;
  334.     end;
  335.   end;
  336. end;
  337.  
  338. procedure TForm1.Copy1Click(Sender: TObject);
  339. begin
  340.   MessageDlg('Clipboard operations not yet supported',mtInformation, [mbOk], 0);
  341. //  Clipboard.Assign(Image.Picture);
  342. end;
  343.  
  344. procedure TForm1.Cut1Click(Sender: TObject);
  345. var
  346.   ARect: TRect;
  347. begin
  348.   Copy1Click(Sender);
  349.   with Image.Canvas do
  350.   begin
  351.     CopyMode := cmWhiteness;
  352.     ARect := Rect(0, 0, Image.Width, Image.Height);
  353.     CopyRect(ARect, Image.Canvas, ARect);
  354.     CopyMode := cmSrcCopy;
  355.   end;
  356. end;
  357.  
  358. procedure TForm1.Paste1Click(Sender: TObject);
  359. var
  360.   Bitmap: TBitmap;
  361. begin
  362.   MessageDlg('Clipboard operations not yet supported',mtInformation, [mbOk], 0);
  363. (*
  364.   if Clipboard.HasFormat(CF_BITMAP) then
  365.   begin
  366.     Bitmap := TBitmap.Create;
  367.     try
  368.       Bitmap.Assign(Clipboard);
  369.       Image.Canvas.Draw(0, 0, Bitmap);
  370.     finally
  371.       Bitmap.Free;
  372.     end;
  373.   end;
  374. *)  
  375. end;
  376.  
  377. procedure TForm1.SaveStyles;
  378. begin
  379.   with Image.Canvas do
  380.   begin
  381.     BrushStyle := Brush.Style;
  382.     PenStyle := Pen.Style;
  383.     PenWide := Pen.Width;
  384.   end;
  385. end;
  386.  
  387. procedure TForm1.RestoreStyles;
  388. begin
  389.   with Image.Canvas do
  390.   begin
  391.     Brush.Style := BrushStyle;
  392.     Pen.Style := PenStyle;
  393.     Pen.Width := PenWide;
  394.   end;
  395. end;
  396.  
  397. constructor TForm1.Create(AOwner: TComponent);
  398. begin
  399.     inherited;
  400.     InitializeControls;
  401. end;
  402. procedure TForm1.InitializeControls;
  403. begin
  404.   // Initalizing all controls...
  405.     Panel1:= TPanel.Create(Self);
  406.     LineButton:= TSpeedButton.Create(Self);
  407.     RectangleButton:= TSpeedButton.Create(Self);
  408.     EllipseButton:= TSpeedButton.Create(Self);
  409.     RoundRectButton:= TSpeedButton.Create(Self);
  410.     PenButton:= TSpeedButton.Create(Self);
  411.     BrushButton:= TSpeedButton.Create(Self);
  412.     PenBar:= TPanel.Create(Self);
  413.     SolidPen:= TSpeedButton.Create(Self);
  414.     DashPen:= TSpeedButton.Create(Self);
  415.     DotPen:= TSpeedButton.Create(Self);
  416.     DashDotPen:= TSpeedButton.Create(Self);
  417.     DashDotDotPen:= TSpeedButton.Create(Self);
  418.     ClearPen:= TSpeedButton.Create(Self);
  419.     PenColor:= TSpeedButton.Create(Self);
  420. //    PenWidth:= TUpDown.Create(Self);
  421.     PenSize:= TEdit.Create(Self);
  422.     BrushBar:= TPanel.Create(Self);
  423.     SolidBrush:= TSpeedButton.Create(Self);
  424.     ClearBrush:= TSpeedButton.Create(Self);
  425.     HorizontalBrush:= TSpeedButton.Create(Self);
  426.     VerticalBrush:= TSpeedButton.Create(Self);
  427.     FDiagonalBrush:= TSpeedButton.Create(Self);
  428.     BDiagonalBrush:= TSpeedButton.Create(Self);
  429.     CrossBrush:= TSpeedButton.Create(Self);
  430.     DiagCrossBrush:= TSpeedButton.Create(Self);
  431.     BrushColor:= TSpeedButton.Create(Self);
  432. //    StatusBar1:= TStatusBar.Create(Self);
  433.     StatusBar1:= TPanel.Create(Self);
  434.     ScrollBox1:= TScrollBox.Create(Self);
  435.     Image:= TImage.Create(Self);
  436.     ColorDialog1:= TColorDialog.Create(Self);
  437.     MainMenu1:= TMainMenu.Create(Self);
  438.     File1:= TMenuItem.Create(Self);
  439.     New1:= TMenuItem.Create(Self);
  440.     Open1:= TMenuItem.Create(Self);
  441.     Save1:= TMenuItem.Create(Self);
  442.     Saveas1:= TMenuItem.Create(Self);
  443.     N1:= TMenuItem.Create(Self);
  444.     Exit1:= TMenuItem.Create(Self);
  445.     Edit1:= TMenuItem.Create(Self);
  446.     Cut1:= TMenuItem.Create(Self);
  447.     Copy1:= TMenuItem.Create(Self);
  448.     Paste1:= TMenuItem.Create(Self);
  449.     OpenDialog1:= TOpenDialog.Create(Self);
  450.     SaveDialog1:= TSaveDialog.Create(Self);
  451.  
  452.     // Form's PMEs'
  453.     Left:= 243;
  454.     Top:= 114;
  455.     Width:= 435;
  456.     Height:= 300;
  457.     Caption:= 'Form1';
  458.     Color:= clBtnFace;
  459.     Font.Charset:= DEFAULT_CHARSET;
  460.     Font.Color:= clWindowText;
  461.     Font.Height:= -11;
  462.     Font.Name:= 'SmallFonts';
  463.     Font.Style:= [];
  464.     Menu:= MainMenu1;
  465.     Position:= poDefault;
  466.     OnCreate:= FormCreate;
  467.     OnMouseDown:= FormMouseDown;
  468.     OnMouseMove:= FormMouseMove;
  469.     OnMouseUp:= FormMouseUp;
  470.     PixelsPerInch:= 96;
  471.     with Panel1 do
  472.     begin
  473.         Parent:= Self;
  474.         Left:= 0;
  475.         Top:= 0;
  476.         Width:= 427;
  477.         Height:= 41;
  478.         Align:= alTop;
  479.         TabOrder:= 0;
  480.     end;
  481.  
  482.     with LineButton do
  483.     begin
  484.         Parent:= Panel1;
  485.         Left:= 8;
  486.         Top:= 8;
  487.         Width:= 30;
  488.         Height:= 30;
  489.         OnClick:= LineButtonClick;
  490.     Glyph.LoadFromFile('line.bmp');
  491.         //  GroupIndex:= 1;
  492. //        Down:= True;
  493.     end;
  494.  
  495.     with RectangleButton do
  496.     begin
  497.         Parent:= Panel1;
  498.         Left:= 40;
  499.         Top:= 8;
  500.         Width:= 30;
  501.         Height:= 30;
  502.     Glyph.LoadFromFile('fsolid.bmp');
  503.         //  GroupIndex:= 1;
  504.         OnClick:= RectangleButtonClick;
  505.     end;
  506.  
  507.  
  508.     with EllipseButton do
  509.     begin
  510.         Parent:= Panel1;
  511.         Left:= 72;
  512.         Top:= 8;
  513.         Width:= 30;
  514.         Height:= 30;
  515.     Glyph.LoadFromFile('ellipse.bmp');
  516.         //  GroupIndex:= 1;
  517.         OnClick:= EllipseButtonClick;
  518.     end;
  519.  
  520.     with RoundRectButton do
  521.     begin
  522.         Parent:= Panel1;
  523.         Left:= 104;
  524.         Top:= 8;
  525.         Width:= 30;
  526.         Height:= 30;
  527.     Glyph.LoadFromFile('roundrec.bmp');
  528.         //  GroupIndex:= 1;
  529.         OnClick:= RoundRectButtonClick;
  530.     end;
  531.  
  532.     with PenButton do
  533.     begin
  534.         Parent:= Panel1;
  535.         Left:= 176;
  536.         Top:= 8;
  537.         Width:= 30;
  538.         Height:= 30;
  539.     Glyph.LoadFromFile('pen.bmp');
  540. //        AllowAllUp:= True;
  541.         //  GroupIndex:= 2;
  542.         OnClick:= PenButtonClick;
  543.     end;
  544.  
  545.     with BrushButton do
  546.     begin
  547.         Parent:= Panel1;
  548.         Left:= 208;
  549.         Top:= 8;
  550.         Width:= 30;
  551.         Height:= 30;
  552.     Glyph.LoadFromFile('brush.bmp');
  553. //        AllowAllUp:= True;
  554.         //  GroupIndex:= 3;
  555.         OnClick:= BrushButtonClick;
  556.     end;
  557.  
  558.     with PenBar do
  559.     begin
  560.         Parent:= Self;
  561.         Left:= 0;
  562.         Top:= 41;
  563.         Width:= 427;
  564.         Height:= 41;
  565.         Align:= alTop;
  566.         TabOrder:= 1;
  567.         Visible:= False;
  568.     end;
  569.  
  570.     with SolidPen do
  571.     begin
  572.         Parent:= PenBar;
  573.         Left:= 8;
  574.         Top:= 8;
  575.         Width:= 30;
  576.         Height:= 30;
  577.     Glyph.LoadFromFile('solid.bmp');
  578.         //  GroupIndex:= 4;
  579. //        Down:= True;
  580.         OnClick:= SetPenStyle;
  581.     end;
  582.  
  583.     with DashPen do
  584.     begin
  585.         Parent:= PenBar;
  586.         Left:= 38;
  587.         Top:= 8;
  588.         Width:= 30;
  589.         Height:= 30;
  590.     Glyph.LoadFromFile('dashed.bmp');
  591.         //  GroupIndex:= 4;
  592.         OnClick:= SetPenStyle;
  593.     end;
  594.  
  595.     with DotPen do
  596.     begin
  597.         Parent:= PenBar;
  598.         Left:= 68;
  599.         Top:= 8;
  600.         Width:= 30;
  601.         Height:= 30;
  602.     Glyph.LoadFromFile('dotted.bmp');
  603.         //  GroupIndex:= 4;
  604.         OnClick:= SetPenStyle;
  605.     end;
  606.  
  607.     with DashDotPen do
  608.     begin
  609.         Parent:= PenBar;
  610.         Left:= 98;
  611.         Top:= 8;
  612.         Width:= 30;
  613.         Height:= 30;
  614.     Glyph.LoadFromFile('dashdot.bmp');
  615.         //  GroupIndex:= 4;
  616.         OnClick:= SetPenStyle;
  617.     end;
  618.  
  619.     with DashDotDotPen do
  620.     begin
  621.         Parent:= PenBar;
  622.         Left:= 128;
  623.         Top:= 8;
  624.         Width:= 30;
  625.         Height:= 30;
  626.     Glyph.LoadFromFile('dashdot2.bmp');
  627.         //  GroupIndex:= 4;
  628.         OnClick:= SetPenStyle;
  629.     end;
  630.  
  631.     with ClearPen do
  632.     begin
  633.         Parent:= PenBar;
  634.         Left:= 158;
  635.         Top:= 8;
  636.         Width:= 30;
  637.         Height:= 30;
  638.     Glyph.LoadFromFile('clear.bmp');
  639.         //  GroupIndex:= 4;
  640.         OnClick:= SetPenStyle;
  641.     end;
  642.  
  643.     with PenColor do
  644.     begin
  645.         Parent:= PenBar;
  646.         Left:= 214;
  647.         Top:= 8;
  648.         Width:= 30;
  649.         Height:= 30;
  650.     Glyph.LoadFromFile('colors.bmp');
  651.         OnClick:= PenColorClick;
  652.     end;
  653. (*
  654.     with PenWidth do
  655.     begin
  656.         Parent:= PenBar;
  657.         Left:= 309;
  658.         Top:= 12;
  659.         Width:= 9;
  660.         Height:= 20;
  661.         Associate:= PenSize;
  662.         ArrowKeys:= False;
  663.         Min:= 0;
  664.         Position:= 1;
  665.         TabOrder:= 0;
  666.         Wrap:= False;
  667.     end;
  668. *)
  669.     with PenSize do
  670.     begin
  671.         Parent:= PenBar;
  672.         Left:= 280;
  673.         Top:= 12;
  674.         Width:= 29;
  675.         Height:= 24;
  676.         TabOrder:= 1;
  677.         Text:= '1';
  678.         OnChange:= PenSizeChange;
  679.     end;
  680.  
  681.     with BrushBar do
  682.     begin
  683.         Parent:= Self;
  684.         Left:= 0;
  685.         Top:= 82;
  686.         Width:= 427;
  687.         Height:= 41;
  688.         Align:= alTop;
  689.         TabOrder:= 2;
  690.         Visible:= False;
  691.     end;
  692.  
  693.     with SolidBrush do
  694.     begin
  695.         Parent:= BrushBar;
  696.         Left:= 8;
  697.         Top:= 8;
  698.         Width:= 30;
  699.         Height:= 30;
  700.     Glyph.LoadFromFile('fsolid.bmp');
  701. //          GroupIndex:= 1;
  702. //        Down:= True;
  703.         OnClick:= SetBrushStyle;
  704.     end;
  705.  
  706.     with ClearBrush do
  707.     begin
  708.         Parent:= BrushBar;
  709.         Left:= 40;
  710.         Top:= 8;
  711.         Width:= 30;
  712.         Height:= 30;
  713.     Glyph.LoadFromFile('fclear.bmp');
  714. //          GroupIndex:= 1;
  715.         OnClick:= SetBrushStyle;
  716.     end;
  717.  
  718.     with HorizontalBrush do
  719.     begin
  720.         Parent:= BrushBar;
  721.         Left:= 72;
  722.         Top:= 8;
  723.         Width:= 30;
  724.         Height:= 30;
  725.     Glyph.LoadFromFile('fhoriz.bmp');
  726. //          GroupIndex:= 1;
  727.         OnClick:= SetBrushStyle;
  728.     end;
  729.  
  730.     with VerticalBrush do
  731.     begin
  732.         Parent:= BrushBar;
  733.         Left:= 104;
  734.         Top:= 8;
  735.         Width:= 30;
  736.         Height:= 30;
  737.     Glyph.LoadFromFile('fvert.bmp');
  738. //          GroupIndex:= 1;
  739.         OnClick:= SetBrushStyle;
  740.     end;
  741.  
  742.     with FDiagonalBrush do
  743.     begin
  744.         Parent:= BrushBar;
  745.         Left:= 136;
  746.         Top:= 8;
  747.         Width:= 30;
  748.         Height:= 30;
  749.     Glyph.LoadFromFile('fdiag.bmp');
  750. //          GroupIndex:= 1;
  751.         OnClick:= SetBrushStyle;
  752.     end;
  753.  
  754.     with BDiagonalBrush do
  755.     begin
  756.         Parent:= BrushBar;
  757.         Left:= 168;
  758.         Top:= 8;
  759.         Width:= 30;
  760.         Height:= 30;
  761.     Glyph.LoadFromFile('bdiag.bmp');
  762. //          GroupIndex:= 1;
  763.         OnClick:= SetBrushStyle;
  764.     end;
  765.  
  766.     with CrossBrush do
  767.     begin
  768.         Parent:= BrushBar;
  769.         Left:= 200;
  770.         Top:= 8;
  771.         Width:= 30;
  772.         Height:= 30;
  773.     Glyph.LoadFromFile('cross.bmp');
  774. //          GroupIndex:= 1;
  775.         OnClick:= SetBrushStyle;
  776.     end;
  777.  
  778.     with DiagCrossBrush do
  779.     begin
  780.         Parent:= BrushBar;
  781.         Left:= 232;
  782.         Top:= 8;
  783.         Width:= 30;
  784.         Height:= 30;
  785.     Glyph.LoadFromFile('dcross.bmp');
  786. //          GroupIndex:= 1;
  787.         OnClick:= SetBrushStyle;
  788.     end;
  789.  
  790.     with BrushColor do
  791.     begin
  792.         Parent:= BrushBar;
  793.         Left:= 279;
  794.         Top:= 8;
  795.         Width:= 30;
  796.         Height:= 30;
  797.     Glyph.LoadFromFile('colors.bmp');
  798.         OnClick:= BrushColorClick;
  799.     end;
  800.  
  801.   // faux status bar
  802.  
  803.     with StatusBar1 do
  804.     begin
  805.         Parent:= Self;
  806.         Left:= 0;
  807. //        Top:= 236;
  808.         Width:= 427;
  809.         Height:= 18;
  810.     BevelOuter := bvLowered;
  811.     BevelWidth := 2;
  812.     Alignment := taLeftJustify;
  813.     Align := alBottom;
  814.     end;
  815.  
  816.     with ScrollBox1 do
  817.     begin
  818.         Parent:= Self;
  819.         Left:= 0;
  820.         Top:= 123;
  821.         Width:= 427;
  822.         Height:= 113;
  823.         Align:= alClient;
  824.     Color := clGray;
  825.         TabOrder:= 4;
  826.     end;
  827.  
  828.     with Image do
  829.     begin
  830.         Parent:= ScrollBox1;
  831.         Left:= 0;
  832.         Top:= 0;
  833.         Width:= 229;
  834.         Height:= 229;
  835.         AutoSize:= True;
  836.         OnMouseDown:= FormMouseDown;
  837.         OnMouseMove:= FormMouseMove;
  838.         OnMouseUp:= FormMouseUp;
  839.     end;
  840.  
  841.     with ColorDialog1 do
  842.     begin
  843.         Parent:= Self;
  844.         Ctl3D:= True;
  845.         Left:= 377;
  846.         Top:= 148;
  847.     end;
  848.     
  849.     with MainMenu1 do
  850.     begin
  851.         Parent:= Self;
  852.         Left:= 337;
  853.         Top:= 148;
  854.     end;
  855.     
  856.     with File1 do
  857.     begin
  858.         MainMenu1.Items.Add(File1);
  859.         Caption:= '&File';
  860.     end;
  861.     
  862.     with New1 do
  863.     begin
  864.         File1.Add(New1);
  865.         Caption:= '&New';
  866.         OnClick:= New1Click;
  867.     end;
  868.     
  869.     with Open1 do
  870.     begin
  871.         File1.Add(Open1);
  872.         Caption:= '&Open...';
  873.         OnClick:= Open1Click;
  874.     end;
  875.     
  876.     with Save1 do
  877.     begin
  878.         File1.Add(Save1);
  879.         Caption:= '&Save';
  880.         OnClick:= Save1Click;
  881.     end;
  882.     
  883.     with Saveas1 do
  884.     begin
  885.         File1.Add(Saveas1);
  886.         Caption:= 'Save &as...';
  887.         OnClick:= Saveas1Click;
  888.     end;
  889.     
  890.     with N1 do
  891.     begin
  892.         File1.Add(N1);
  893.         Caption:= '-';
  894.     end;
  895.     
  896.     with Exit1 do
  897.     begin
  898.         File1.Add(Exit1);
  899.         Caption:= 'E&xit';
  900.         OnClick:= Exit1Click;
  901.     end;
  902.     
  903.     with Edit1 do
  904.     begin
  905.         MainMenu1.Items.Add(Edit1);
  906.         Caption:= '&Edit';
  907.     end;
  908.     
  909.     with Cut1 do
  910.     begin
  911.         Edit1.Add(Cut1);
  912.         Caption:= 'Cu&t';
  913.         ShortCut:= 16472;
  914.         OnClick:= Cut1Click;
  915.     end;
  916.     
  917.     with Copy1 do
  918.     begin
  919.         Edit1.Add(Copy1);
  920.         Caption:= '&Copy';
  921.         ShortCut:= 16451;
  922.         OnClick:= Copy1Click;
  923.     end;
  924.     
  925.     with Paste1 do
  926.     begin
  927.         Edit1.Add(Paste1);
  928.         Caption:= '&Paste';
  929.         ShortCut:= 16470;
  930.         OnClick:= Paste1Click;
  931.     end;
  932.  
  933.     with OpenDialog1 do
  934.     begin
  935.         Parent := Self;
  936.         DefaultExt:= 'bmp';
  937.         Filter:= 'Bitmaps|(*.bmp)';
  938.     Left := 337;
  939.         Top := 188;
  940.     end;
  941.  
  942.     with SaveDialog1 do
  943.     begin
  944.         Parent:= Self;
  945.         DefaultExt:= 'bmp';
  946.         Filter:= 'Bitmaps|(*.bmp)';
  947.     Left := 377;
  948.         Top:= 188;
  949.     end;
  950.   FormCreate(Self);
  951. end;
  952.  
  953. end.
  954.